<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>inspinia 2.9.2 | 登录</title>

    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
    <link href="/layer/theme/default/layer.css" rel="stylesheet">

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name">IN+</h1>
            </div>
            <h3>欢迎登录inspinia 2.9.2</h3>
            <p>一套高质量的后台管理html模板</p>
            <form id="form1" class="m-t" role="form" action="" method="post">
                <div class="form-group">
                    <input type="text" name="username" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" name="password" class="form-control" placeholder="密码" required="">
                </div>
                <button type="button" class="layui-btn btn btn-primary block full-width m-b" onclick="login()">登录</button>

                <a href="#"><small>忘记密码?</small></a>
                <p class="text-muted text-center"><small>还没有账号?</small></p>
                <a class="btn btn-sm btn-white btn-block" href="zhipage/register.html">创建一个帐户</a>
            </form>
            <p class="m-t"> <small>Copyright</strong> inspinia 2.9.2 &copy; 2017-2018</small> </p>
        </div>
    </div>

    <!-- Mainly scripts -->
    <script src="/js/jquery-3.1.1.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.js"></script>
    <script src="/layer/layer.js"></script>
<script>
        function login() {
            $(this).text("登录中...").attr("disabled", "disabled").addClass("layui-disabled");
            var index = layer.msg('登录中，请稍候', {
                icon: 16,
                time: false,
                shade: 0.8
            });
            var username = $("input[name='username']").val();
            var userpassword =$("input[name='password']").val();
            var data = {"username": username,"pwd": userpassword};
            $.ajax({
                type: "Post", //http通信传参方式
                url: "/user/login", //服务器端资源
                dataType: "json", //服务器传值格式
                data: $('#form1').serialize(),
                //回调函数：
                success: function (data) {
                    console.log(data)
                    if(data.success){
                        // if(user.status!=0||user.status!="0"){
                        //     layer.msg('你的账户已被锁定，请联系管理员！', {icon: 4});
                        // }else{
                            window.location.href ="/"
                        // }
                    }else{
                        layer.msg('账户不存在！', {icon: 2});
                    }
                },
                error: function (err) {
                    console.log(err);
                }
            });
    }

</script>
</body>

</html>
